package com.budwk.app.sqfw.controllers.admin;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.budwk.app.sqfw.dto.SimpleCenSusPaperQueryDTO;
import com.budwk.app.sqfw.models.Sqfw_cenSusPaper;
import com.budwk.app.sqfw.services.SqfwCenSusPaperService;
import com.budwk.starter.common.openapi.annotation.ApiDefinition;
import com.budwk.starter.common.openapi.annotation.ApiOperation;
import com.budwk.starter.common.openapi.annotation.ApiResponse;
import com.budwk.starter.common.result.Result;
import com.budwk.starter.log.annotation.SLog;
import com.budwk.starter.security.utils.SecurityUtil;
import lombok.extern.slf4j.Slf4j;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.POST;
import org.nutz.mvc.annotation.Param;

import java.util.List;

/**
 * @author ZY.Wang
 * @since 2023/10/23
 */
@IocBean
@At("/platform/sqfw/cenSusPaper")
@ApiDefinition(tag = "住戶信息相关接口")
@Slf4j
public class SqfwCenSusPaperController {

    @Inject
    private SqfwCenSusPaperService sqfwCenSusPaperService;

    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "新增人口调查表")
    @ApiResponse
    @SLog(tag = "新增人口调查", value = "${args[0]}}")
    @SaCheckLogin
    public Result<?> addCenSusPaper(@Param("..") Sqfw_cenSusPaper cenSusPaper) {
        sqfwCenSusPaperService.add(cenSusPaper);
        return Result.success("新增成功");
    }

    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "查询人口调查")
    @ApiResponse
    @SLog(tag = "查询人口调查", value = "${args[0]}")
    @SaCheckLogin
    public Result<?> listCenSusPaper(@Param("..") Sqfw_cenSusPaper cenSusPaper) {
        List<Sqfw_cenSusPaper> list = sqfwCenSusPaperService.listCenSusPaper(cenSusPaper);
        return Result.success(list);
    }

    /**
     * wzy 2023-11-30 查询特殊人员列表
     *
     * @param queryDTO 查询条件DTO
     * @return 结果
     */
    @At("/listHouseSurveyCenPeople")
    @Ok("json")
    @POST
    @ApiOperation(name = "查询特殊人员数据")
    @SLog(tag = "查询特殊人员数据", value = "${args[0]}")
    @SaCheckLogin
    public Result<?> listHouseSurveyCenPeople(@Param("..") SimpleCenSusPaperQueryDTO queryDTO) {
        String userId = SecurityUtil.getUserId();
        List<Sqfw_cenSusPaper> list = sqfwCenSusPaperService.listHouseSurveyCenPeople(queryDTO, userId);
        return Result.data(list);
    }
}
